<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改集中器型号数据')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-type-edit" th:object="${baseConcentratorType}">
            <input name="typeId" th:field="*{typeId}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">集中器型号：</label>
                <div class="col-sm-8">
                    <input name="typeName" id="typeName" th:field="*{typeName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">容量：</label>
                <div class="col-sm-8">
                    <input name="concentratorVolume" th:field="*{concentratorVolume}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">设备厂商：</label>
                <div class="col-sm-8">
                    <select id="factoryId" name="factoryId" class="form-control">
                        <option th:each="factory:${factorys}" th:value="${factory.factoryId}" th:text="${factory.factoryName}" th:field="*{factoryId}"></option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "module/concentrator";
        $("#form-type-edit").validate({
            onkeyup: false,
            rules: {
                typeName: {
                    remote: {
                        url: prefix + "/checkConcentratorTypeCodeUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "typeName": function() {
                                return $.common.trim($("#typeName").val());
                            }
                        },
                        dataFilter: function(data, type) {
                            return $.validate.unique(data);
                        }
                    }
                },
            },
            messages: {
                "typeName": {
                    remote: "集中器型号已存在"
                }
            },

            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-type-edit').serialize());
            }
        }
    </script>
</body>
</html>